package org.dm.TestCase;

import com.alibaba.fastjson2.JSONObject;
import okhttp3.Headers;
import okhttp3.Response;
import org.dm.controller.HttpController;
import org.testng.annotations.Test;

import java.util.HashMap;
import java.util.logging.Logger;

public class PmsTest {
    HttpController controller = HttpController.getInstance();
    String pmsUrl = "https://pms-pms-app-staging.apps.haitcds.org" ;


    @Test
    public void loginPms() throws Exception {
        String url = "/api/security/login";
        HashMap<String,String> hashMap = new HashMap<>();
//        hashMap.put("user-agent","Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.114 Safari/537.36");
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("hospCode","QMH");
        jsonObject.put("password", "Qwer1234");
        jsonObject.put("username", "itdadmin");
        jsonObject.put("workstoreCode", "WKS1");

        Response response = controller.doPost(pmsUrl+url,hashMap,jsonObject);

        assert response.code()==200;
        Logger.getGlobal().info("Body:---------------\n" + controller.getJsonBody(response));
        Logger.getGlobal().info("headers:---------------\n" + response.headers());
        Logger.getGlobal().warning("request headers:---------------\n" + response.request().headers());
    }
}
